﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DatabaseAccess;

using System.Data;
using System.Text;

 
 

namespace Liguo.Administration
{
    public partial class OrderInquiry : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String userName = "";
            if (Request["UserName"] != null)
                userName = Request["UserName"].ToString();
            if (userName != null && !userName.Equals(""))
                TextBox_UserName.Text = userName;
            //下拉框的数据绑定  
                SqlIt sql = new SqlIt();
                DataSet dataset = sql.SelectAll("OrderStatus");
                DropDownList_OrderStatus.DataSource = dataset.Tables[0].DefaultView;
                DropDownList_OrderStatus.DataTextField = "Status";
                DropDownList_OrderStatus.DataValueField = "ID";
           if (!IsPostBack)
           {
                DropDownList_OrderStatus.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //第一步：获取有关属性     
            String userName = TextBox_UserName.Text;         
            String timeLowBound = startTime.Text;         
            String timeUpBound = endTime.Text;
            int orderId = int.Parse(DropDownList_OrderStatus.SelectedItem.Value);       //获得绑定的数值关键字
            String teststr = DropDownList_OrderStatus.SelectedItem.Text;
            //如果orderId 转换有问题会有异常抛出


            //二：获取查询用的userID
            if (!userName.Equals(""))
            {
                SqlIt sql = new SqlIt();
                String condition = "UserName=" + "'" + userName + "'";
                String field = "ID";
                Object sendId =  sql.SingleSpecialItem("UserInfo", condition, field);
                if (!(sendId == null))
                {
                    Session["userId"] = sendId.ToString();
                    
                }
            }
            else
            {
                Session["userId"] = "";
            }
           
            
            //第三步：保证所传的参数都是String
             
            String sendTimeLowBound="";
                //
            String sendTimeUpBound="";
               // = 
            String sendOrderTypeID = orderId.ToString();
            if (timeLowBound!= null && !timeLowBound.Equals(""))
            {
                sendTimeLowBound = timeLowBound;
            }
            if (timeUpBound != null && !timeUpBound.Equals(""))
            {
                sendTimeUpBound = timeUpBound;
            }
           

            Session["sendTimeLowBound"] = sendTimeLowBound;
            Session["sendTimeUpBound"] = sendTimeUpBound;
            Session["sendOrderTypeID"] = sendOrderTypeID;

            Response.Redirect("/Administration/OrderSimpleInfo.aspx");
        }


    }
}